import ChildFun from './components/ChildFun'
import ChildCla from './components/ChildCla';
import React, { useMemo, useState } from "react";

function App(){ 
  const [a, setA] = useState(0);
  const [b, setB] = useState(0);
  const result = useMemo(() => {
    console.log("计算结果");
    return a + b;
  }, [a, b]);
  const re=()=>{
    console.log("js")
    return a+b;
  }


  return (<div>
    <h1>函数组件</h1>  
    <ChildFun></ChildFun>

    <h1>类组件</h1> 
    <ChildCla></ChildCla>

    <p>a: {a}</p>
      <p>b: {b}</p>
      <p>result: {result}</p>
      <p>{re()}</p>
      <button onClick={() => setA(a + 1)}>加 a</button>
      <button onClick={() => setB(b + 1)}>加 b</button>

    </div>) 
}
export default App;